package com.jiaquyun.jcyx.jetpack.mode

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.jiaquyun.jcyx.base.BaseViewModel
import com.jiaquyun.jcyx.entity.AddressListResponse
import com.jiaquyun.jcyx.entity.ArticleDetailsResponse
import com.jiaquyun.jcyx.entity.ArticleListResponse
import com.jiaquyun.jcyx.jetpack.api.ArticleRepository
import com.jiaquyun.jcyx.jetpack.api.UserRepository
import com.module.lemlin.http.HttpResponseBody
import com.module.lemlin.http.SubscribeViewModel

class ArticleViewModel(application: Application) : BaseViewModel(application) {

    private val mArticleRepository = ArticleRepository()

    val articleListLiveData = MutableLiveData<HttpResponseBody<ArticleListResponse>>()
    fun articleList(type: String) {
        setRxLifeScope(SubscribeViewModel(articleListLiveData)) {
            mArticleRepository.articleList(type)
        }
    }

    val articleDetailsLiveData = MutableLiveData<HttpResponseBody<ArticleDetailsResponse>>()
    fun articleDetails(id: Int) {
        setRxLifeScope(SubscribeViewModel(articleDetailsLiveData)) {
            mArticleRepository.articleDetails(id.toString())
        }
    }
}